package com.zm.exam.springbootexam.controller;


import com.zm.exam.springbootexam.biz.ExanBiz;
import com.zm.exam.springbootexam.entry.Exam;
import com.zm.exam.springbootexam.entry.Result;
import com.zm.exam.springbootexam.entry.User;
import com.zm.exam.springbootexam.mapper.ExamMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.SessionAttribute;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zm
 * @since 2024-08-14
 */
@RestController
@RequestMapping("/exam")
public class ExamController {
    @Autowired
    ExanBiz exanBiz;
    @Autowired
    ExamMapper examMapper;
    @RequestMapping("commit")
    public Result commit(@RequestBody Exam exam, @SessionAttribute User myinfo){
        exam.setUid(myinfo.getId());
        exanBiz.commit(exam);
        return new Result(1,"提交成功",exam);
    }

    @RequestMapping("get")
    public Exam get(int pid, @SessionAttribute User myinfo){
        return  examMapper.findById(pid,myinfo.getId());
    }

}

